package com.easy.controller;


import com.easy.bean.FosterBean;
import com.easy.service.FosterBeanService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin//允许请求跨域
@RequestMapping("foster")
public class FosterController {
    @Autowired
    FosterBeanService fosterBeanService;

    @PostMapping
    public Result add(@RequestBody FosterBean fosterBean){
        Object obj=fosterBeanService.add(fosterBean);
        return Result.success(obj);
    }

    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj=fosterBeanService.del(id);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody FosterBean fosterBean){
        Object obj=fosterBeanService.edit(fosterBean);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(FosterBean fosterBean){
        Object obj=fosterBeanService.all(fosterBean);
        return Result.success(obj);
    }

    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=fosterBeanService.one(id);
        return Result.success(obj);
    }
    @GetMapping("page")
    public Result page(Page page,FosterBean fosterBean){
        fosterBeanService.page(page,fosterBean);
        return Result.success(page);
    }

}


































